package enumandlambda;

import java.time.LocalDateTime;

/**
 * @author shkstart
 * 关于join
 * @create 2022-12-01-11:51
 */
public class ThreadDemoByJoin {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            //1.张三上班
            System.out.println("1.张三开始上班"+ LocalDateTime.now());
            //2.张三正在上班
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            //张三下班
            System.out.println("3.张三下班"+ LocalDateTime.now());
        });
        //启动
        t1.start();

        //等待t1执行完之后再执行剩下的线程
        t1.join();

        Thread t2 = new Thread(() -> {
            //1.李四开始上班
            System.out.println("1.李四开始上班"+ LocalDateTime.now());
            //2.李四正在上班
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            //3.李四下班
            System.out.println("3.李四下班"+ LocalDateTime.now());
        });
        t2.start();
    }
}